package com.lanou.pro;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

/**
 * @author zyj
 * @date 2022年06月11日 14:47
 */
public class Client {
    public static void main(String[] args) {
        Socket socket = null;
        PrintStream send = null;
        BufferedReader input = null;
        PrintStream print = null;
        try {
            socket = new Socket("localhost", 80);
            input = new BufferedReader(new InputStreamReader(System.in));
            print = new PrintStream(System.out);
            send = new PrintStream(socket.getOutputStream());
            while (true){
                print.println("请输入发送的消息");
                String message = input.readLine();
                send.println(message);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
